/*
 * OpenSceneGraph + Qt + Offscreen rendering example.
 * Copyright (C) 2011  Gonzalo Exequiel Pedone
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with This program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Email   : hipersayan DOT x AT gmail DOT com
 * Web-Site: http://hipersayanx.blogspot.com/
 */

#include "../include/mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow)
{
    // Cargamos la interfaz prediseñada.
    ui->setupUi(this);

    // Redimensionamos el QOSGWidget al tamaño de lños frames que queremos renderizar.
    osg_widget.resize(640, 480);

    // Mostraremos un nuevo frame cada 1 ms.
    timer.setInterval(1);
    connect(&timer, SIGNAL(timeout()), this, SLOT(show_frame()));
    timer.start();
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::show_frame()
{
    // Obtenemos un frame y lo mostramos a travez de una QLabel.
    ui->lblScene->setPixmap(osg_widget.renderPixmap());
}
